* (bug 24136) unknownerror when adding new section without summary, but forceditsummary
authorSam Reed <reedy@users.mediawiki.org>
Sun, 27 Jun 2010 19:22:46 +0000 (19:22 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sun, 27 Jun 2010 19:22:46 +0000 (19:22 +0000)
Handle AS_SUMMARY_NEEDED in ApiEditPage

Fixup some braces

RELEASE-NOTES
includes/api/ApiBase.php
includes/api/ApiEditPage.php

index 541834e..4e56a68 100644 (file)
@@ -245,7 +245,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 24016) API: Handle parameters specified in simple string syntax 
   ( 'paramname' => 'defaultval' ) correctly when outputting help
 * (bug 24089) Logevents causes PHP Notice if leprop=title isn't supplied
-* (bug 23473) - Give description of properties on all modules
+* (bug 23473) Give description of properties on all modules
+* (bug 24136) unknownerror when adding new section without summary, but forceditsummary
 
 === Languages updated in 1.17 ===
 
index 3656c2c..6023169 100644 (file)
@@ -928,6 +928,7 @@ abstract class ApiBase {
                'userrights-nodatabase' => array( 'code' => 'nosuchdatabase', 'info' => "Database ``\$1'' does not exist or is not local" ),
                'nouserspecified' => array( 'code' => 'invaliduser', 'info' => "Invalid username ``\$1''" ),
                'noname' => array( 'code' => 'invaliduser', 'info' => "Invalid username ``\$1''" ),
+               'summaryrequired' => array( 'code' => 'summaryrequired', 'info' => 'Summary required'),
 
                // API-specific messages
                'readrequired' => array( 'code' => 'readapidenied', 'info' => "You need read permission to use this module" ),
index 48759ba..7cd5769 100644 (file)
@@ -117,16 +117,14 @@ class ApiEditPage extends ApiBase {
                                $undoafterRev = Revision::newFromID( $params['undoafter'] );
                        }
                        $undoRev = Revision::newFromID( $params['undo'] );
-                       if ( is_null( $undoRev ) || $undoRev->isDeleted( Revision::DELETED_TEXT ) )
-                       {
+                       if ( is_null( $undoRev ) || $undoRev->isDeleted( Revision::DELETED_TEXT ) ) {
                                $this->dieUsageMsg( array( 'nosuchrevid', $params['undo'] ) );
                        }
 
                        if ( $params['undoafter'] == 0 ) {
                                $undoafterRev = $undoRev->getPrevious();
                        }
-                       if ( is_null( $undoafterRev ) || $undoafterRev->isDeleted( Revision::DELETED_TEXT ) )
-                       {
+                       if ( is_null( $undoafterRev ) || $undoafterRev->isDeleted( Revision::DELETED_TEXT ) ) {
                                $this->dieUsageMsg( array( 'nosuchrevid', $params['undoafter'] ) );
                        }
 
@@ -144,8 +142,7 @@ class ApiEditPage extends ApiBase {
                        $params['text'] = $newtext;
                        // If no summary was given and we only undid one rev,
                        // use an autosummary
-                       if ( is_null( $params['summary'] ) && $titleObj->getNextRevisionID( $undoafterRev->getID() ) == $params['undo'] )
-                       {
+                       if ( is_null( $params['summary'] ) && $titleObj->getNextRevisionID( $undoafterRev->getID() ) == $params['undo'] ) {
                                $params['summary'] = wfMsgForContent( 'undo-summary', $params['undo'], $undoRev->getUserText() );
                        }
                }
@@ -170,8 +167,7 @@ class ApiEditPage extends ApiBase {
 
                // Watch out for basetimestamp == ''
                // wfTimestamp() treats it as NOW, almost certainly causing an edit conflict
-               if ( !is_null( $params['basetimestamp'] ) && $params['basetimestamp'] != '' )
-               {
+               if ( !is_null( $params['basetimestamp'] ) && $params['basetimestamp'] != '' ) {
                        $reqArr['wpEdittime'] = wfTimestamp( TS_MW, $params['basetimestamp'] );
                } else {
                        $reqArr['wpEdittime'] = $articleObj->getTimestamp();
@@ -193,8 +189,7 @@ class ApiEditPage extends ApiBase {
 
                if ( !is_null( $params['section'] ) ) {
                        $section = intval( $params['section'] );
-                       if ( $section == 0 && $params['section'] != '0' && $params['section'] != 'new' )
-                       {
+                       if ( $section == 0 && $params['section'] != '0' && $params['section'] != 'new' ) {
                                $this->dieUsage( "The section parameter must be set to an integer or 'new'", "invalidsection" );
                        }
                        $reqArr['wpSection'] = $params['section'];
@@ -229,8 +224,7 @@ class ApiEditPage extends ApiBase {
                }
 
                $r = array();
-               if ( !wfRunHooks( 'APIEditBeforeSave', array( $ep, $ep->textbox1, &$r ) ) )
-               {
+               if ( !wfRunHooks( 'APIEditBeforeSave', array( $ep, $ep->textbox1, &$r ) ) ) {
                        if ( count( $r ) ) {
                                $r['result'] = 'Failure';
                                $this->getResult()->addValue( null, $this->getModuleName(), $r );
@@ -324,6 +318,9 @@ class ApiEditPage extends ApiBase {
                                                $newArticle->getTimestamp() );
                                }
                                break;
+                       
+                       case EditPage::AS_SUMMARY_NEEDED:
+                               $this->dieUsageMsg( array( 'summaryrequired' ) );
 
                        case EditPage::AS_END:
                                // This usually means some kind of race condition